package com.bsoft.advance.core.common;

import lombok.Data;

import java.io.Serializable;

@Data
public class RpcResponse implements Serializable {

    /**
     * 消息
     */
    private Object data;
    /**
     * 异常信息
     */
    private String errMsg;

    /**
     * 心跳
     */
    private String heartbeat;

    /**
     * 心跳响应结果
     */
    private static final String HEARTBEAT_RESPONSE = "PONG";


    /**
     * 构建心跳响应
     */
    public static RpcResponse buildHeartBeat() {
        RpcResponse response = new RpcResponse();
        response.heartbeat = HEARTBEAT_RESPONSE;
        return response;
    }

    /**
     * 心跳是否正常响应
     * @return
     */
    public boolean isHeartbeatSuccess() {
        return heartbeat == HEARTBEAT_RESPONSE;
    }

}
